package top.infopub.mgr.fia.service.impl;


import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.fia.dao.SuperBudgetOfgroupDao;
import top.infopub.mgr.fia.dao.SuperBudgetOfgroupDtlDao;
import top.infopub.mgr.fia.domain.SuperBudgetOfgroupDomain;
import top.infopub.mgr.fia.service.SuperBudgetOfgroupService;
import top.infopub.mgr.fia.vo.SuperBudgetOfgroupVo;
import top.infopub.model.fia.SuperBudgetOfgroup;
import top.infopub.model.fia.SuperBudgetOfgroupDtl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;


@Service
public class SuperBudgetOfgroupServiceImpl extends GenericServiceImpl<SuperBudgetOfgroup, String> implements SuperBudgetOfgroupService {

    @Autowired
    private SuperBudgetOfgroupDao superBudgetOfgroupDao;

    @Autowired
    private SuperBudgetOfgroupDtlDao superBudgetOfgroupDtlDao;

    @Override
    public GenericDao<SuperBudgetOfgroup, String> getDao() {
        return superBudgetOfgroupDao;
    }

    @Override
    public Page<SuperBudgetOfgroupDomain> selectByDomainWhere(Page<SuperBudgetOfgroupDomain> page,
                                                              SuperBudgetOfgroupVo superBudgetOfgroupVo) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        return (Page<SuperBudgetOfgroupDomain>)superBudgetOfgroupDao.selectByDomainWhere(superBudgetOfgroupVo);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveSuperBudgetOfgroup(SuperBudgetOfgroup superBudgetOfgroup,
                                       List<SuperBudgetOfgroupDtl> superBudgetOfgroupDtls) {

        superBudgetOfgroupDao.insertById(superBudgetOfgroup);

        if (CollectionUtils.isNotEmpty(superBudgetOfgroupDtls)) {
            superBudgetOfgroupDtlDao.insertByBatch(superBudgetOfgroupDtls);
        }
    }

    @Override
    public SuperBudgetOfgroupVo queryById(String id) {
        return superBudgetOfgroupDao.queryById(id);
    }

    /*@Override
    @Transactional(rollbackFor = Exception.class)
    public void udpSuperBudgetOfgroup(SuperBudgetOfgroupVo superBudgetOfgroupVo) {

        SuperBudgetOfgroup superBudgetOfgroup = superBudgetOfgroupDao.selectByPrimaryKey(superBudgetOfgroupVo.getId());
        BeanUtils.copyProperties(superBudgetOfgroupVo, superBudgetOfgroup);
        superBudgetOfgroup.setProcessStatus("9");
        superBudgetOfgroup.setUptTime(new Date());
        superBudgetOfgroup.setUptBy(SessionUserUtils.getSessionUserId());
        this.updateBySelective(superBudgetOfgroup);

    }*/

}